/**
 * @description 汇总组件
 * @author wangjianjun
 */

import React, { PureComponent } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Row, Col, Divider } from 'antd';
import accounting from 'accounting';
import style from '../index.less';

@Form.create()
export default class TotalAccount extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }
  showTab = () => {
    let account = this.props.account;
    switch (this.props.type) {
      case '1':
        return (
          <Row style={{ marginLeft: '10px' }}>
            {account.valdiffTotal || account.valdiffTotal == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>总估值偏离&nbsp;&nbsp;{`${account.valdiffTotal}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`总估值偏离`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.marketValue || account.marketValue == 0 ? (
              <Col span={4}>
                {' '}
                <span>市值&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.marketValue), 4)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`市值`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.enFloatProfit || account.enFloatProfit == 0 ? (
              <Col span={4}>
                {' '}
                <span>浮动盈亏&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.enFloatProfit), 4)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`浮动盈亏`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.costRatio || account.costRatio == 0 ? (
              <Col span={4}>
                {' '}
                <span>成本收益率&nbsp;&nbsp;{`${account.costRatio}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`成本收益率`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.exerciseCostRatio || account.exerciseCostRatio == 0 ? (
              <Col span={4}>
                {' '}
                <span>成本收益率（行权）&nbsp;{`${account.exerciseCostRatio}`}</span>{' '}
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>成本收益率（行权）--</span>
              </Col>
            )}
            {account.bondDuration || account.bondDuration == 0 ? (
              <Col span={4}>
                {' '}
                <span>纯债久期&nbsp;{`${account.bondDuration}`}</span>{' '}
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>纯债久期 --</span>
              </Col>
            )}
          </Row>
        );
        break;
      case '2':
        return (
          <Row style={{ marginLeft: '10px' }}>
            {account.amount || account.amount == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>回购金额&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.amount), 4)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`回购金额`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.enFloatProfit || account.enFloatProfit == 0 ? (
              <Col span={5}>
                {' '}
                <span>浮动盈亏&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.enFloatProfit), 4)}`}</span>
              </Col>
            ) : (
              <Col span={5}>
                {' '}
                <span>{`浮动盈亏`}&nbsp;&nbsp;--</span>{' '}
              </Col>
            )}
          </Row>
        );
        break;
      case '3':
        return (
          <Row style={{ marginLeft: '10px' }}>
            {account.buyNum || account.buyNum == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>买入开仓数量&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.buyNum))}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`买入开仓数量`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.saleNum || account.saleNum == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>卖出开仓数量&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.saleNum))}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>{`卖出开仓数量`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.marketValue || account.marketValue == 0 ? (
              <Col span={5}>
                {' '}
                <span>市值&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.marketValue), 4)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={5}>
                {' '}
                <span>{`市值`}&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.enFloatProfit || account.enFloatProfit == 0 ? (
              <Col span={7}>
                {' '}
                <span>浮动盈亏&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.enFloatProfit), 4)}`}</span>
              </Col>
            ) : (
              <Col span={5}>
                {' '}
                <span>{`浮动盈亏`}&nbsp;&nbsp;--</span>{' '}
              </Col>
            )}
          </Row>
        );
        break;
      case '4':
        return (
          <Row style={{ marginLeft: '10px' }}>
            {account.zhgBalance || account.zhgBalance == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>正回购金额&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.zhgBalance), 2)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>正回购金额&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.lhgBalance || account.lhgBalance == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>逆回购金额&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.lhgBalance), 2)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>逆回购金额&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.totalProfit || account.totalProfit == 0 ? (
              <Col span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>累计收益&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.totalProfit), 2)}`}</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>
              </Col>
            ) : (
              <Col span={4}>
                {' '}
                <span>累计收益&nbsp;&nbsp;--</span>{' '}
                <span className={style.shuxian}>
                  <Divider type='vertical' />
                </span>{' '}
              </Col>
            )}
            {account.expectProfit || account.expectProfit == 0 ? (
              <Col span={5}>
                {' '}
                <span>预期收益&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.expectProfit), 2)}`}</span>
              </Col>
            ) : (
              <Col span={5}>
                {' '}
                <span>预期收益&nbsp;&nbsp;--</span>{' '}
              </Col>
            )}
          </Row>
        );
        break;
      case '5':
        return (
          <Row style={{ marginLeft: '10px', display: 'flex' }} className={style.myRow}>
            {account.amount || account.amount == 0 ? (
              <div span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>数量&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.amount))}`}</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>
              </div>
            ) : (
              <div span={4}>
                {' '}
                <span>{`数量`}&nbsp;&nbsp;--</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>{' '}
              </div>
            )}
            {account.marketValue || account.marketValue == 0 ? (
              <div span={5}>
                {' '}
                <span>市值&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.marketValue), 4)}`}</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>
              </div>
            ) : (
              <div span={5}>
                {' '}
                <span>{`市值`}&nbsp;&nbsp;--</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>{' '}
              </div>
            )}
          </Row>
        );
        break;
      default:
        return (
          <Row style={{ marginLeft: '10px', display: 'flex' }} className={style.myRow}>
            {account.amount || account.amount == 0 ? (
              <div span={4}>
                {' '}
                <span style={{ paddingLeft: '20px' }}>数量&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.amount))}`}</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>
              </div>
            ) : (
              <div span={4}>
                {' '}
                <span>{`数量`}&nbsp;&nbsp;--</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>{' '}
              </div>
            )}
            {account.marketValue || account.marketValue == 0 ? (
              <div span={5}>
                {' '}
                <span>市值&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.marketValue), 4)}`}</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>
              </div>
            ) : (
              <div span={5}>
                {' '}
                <span>{`市值`}&nbsp;&nbsp;--</span>{' '}
                <span>
                  <Divider type='vertical' />
                </span>{' '}
              </div>
            )}
            {account.enFloatProfit || account.enFloatProfit == 0 ? (
              <div span={7}>
                {' '}
                <span>浮动盈亏&nbsp;&nbsp;{`${accounting.formatNumber(Number(account.enFloatProfit), 4)}`}</span>
              </div>
            ) : (
              <div span={5}>
                {' '}
                <span>{`浮动盈亏`}&nbsp;&nbsp;--</span>{' '}
              </div>
            )}
          </Row>
        );
    }
  };
  render() {
    return (
      <div className={style.accountRow} style={{ marginTop: '10px' }}>
        {this.showTab()}
      </div>
    );
  }
}
